#!/bin/bash

# 主仓库地址
vhallAppGitUrl='http://47.94.241.60:8082/vhall-app/backend-java.git'
vhallApp='vhall-app'
originBranch=${vhallApp}/$1

echo ${originBranch} " will be merged"

# 检查是否添加主仓库
if [[ `git remote | grep ${vhallApp}` == '' ]];
then
    echo "remote not exist will be added"
    git remote add ${vhallApp} ${vhallAppGitUrl}
else
    echo "remote exist"
fi

echo "git remote update"
git remote update

# 检查远程分支是否存在
if [[ `git branch -a | grep ${originBranch}` = '' ]];
then
  echo "git remote ${vhallApp} branch not exist"
  exit
fi

# 同步主仓库 需求分支 到本地 开发 分支
git merge --no-commit --no-ff ${originBranch}

if [ $? -ne 0 ];
then
  echo "git merge not success, please attention to commit"
else
  echo "git merge finish"
fi




